<template>
  <div class="waiting-info">
    <template v-if="true">
      <div class="list-item-setting">
        <div class="title-info">
          <el-divider content-position="left">区域设置</el-divider>
        </div>
        <el-form-item label="展示行数">
          <el-input-number
              :min="4"
              :max="6"
              v-model="optionsInfo.showRowNums"
              class="hide-spin-button"
              size="small"
          />
        </el-form-item>
        <el-form-item label="行高">
          <el-input-number
              v-model="optionsInfo.lineHeight"
              :min="0"
              size="small"
              class="hide-spin-button"
          />
        </el-form-item>
        <el-form-item label="内容高度">
          <el-input-number
              v-model="optionsInfo.contentHeight"
              :min="0"
              size="small"
              class="hide-spin-button"
          />
        </el-form-item>
      </div>

      <div class="list-title-setting">
        <div class="title-info">
          <el-divider content-position="left">列表头部设置</el-divider>
        </div>
        <el-form-item label="是否显示">
          <el-switch v-model="optionsInfo.headShow"/>
        </el-form-item>
        <el-form-item label="背景颜色">
          <el-color-picker
              size="small"
              show-alpha
              :predefine="predefineColors"
              v-model="optionsInfo.headerBackgroundColor"/>
        </el-form-item>
        <el-form-item label="字体颜色">
          <el-color-picker
              size="small"
              show-alpha
              :predefine="predefineColors"
              v-model="optionsInfo.headerFontColor"/>
        </el-form-item>
        <el-form-item label="高度">
          <el-input-number
              :min="0"
              size="small"
              class="hide-spin-button"
              v-model="optionsInfo.headHeight"
          />
        </el-form-item>
        <el-form-item class="col-info">
          <div class="title">
            <el-divider content-position="center">显示列</el-divider>
          </div>
          <div class="options-info">
            <el-checkbox-group v-model="optionsInfo.defaultShowCol">
              <Draggable
                  class="list-group"
                  @end="handleDragEnd"
                  :list="(optionsInfo.colOptions)"
                  :animation="100"
              >
                <el-checkbox
                    :label="item.value"
                    v-for="(item,index) in (optionsInfo.colOptions)"
                    :key="index"
                    :disabled="isDisabled(item.value)"
                >
                  <el-input v-model="item.label" placeholder="请输入内容" size="small"/>
                  <i class="el-icon-thumb"></i>
                </el-checkbox>
              </Draggable>
            </el-checkbox-group>
          </div>
        </el-form-item>
      </div>

      <div class="list-item-setting">
        <div class="title-info">
          <el-divider content-position="left">诊室设置</el-divider>
        </div>
        <div>
          <roomNameKeyEditor
              businessType="special"
              :designer="designer"
              :selected-widget="selectedWidget"
              :option-model="optionModel"
          />
        </div>
      </div>


      <el-form-item class="register-info" v-if="(optionsInfo.defaultShowCol).includes('registerObjNames')">
        <div class="title">
          <el-divider content-position="center">号别类型</el-divider>
        </div>
        <div class="options-info">
          <el-radio-group v-model="optionsInfo.registerObjNameKey">
            <el-radio
                :label="item.dictValue"
                :value="item.dictValue"
                :key="item.dictValue"
                v-for="item in registerObjNameOptions"
            >
              {{item.dictLabel}}
            </el-radio>
          </el-radio-group>
        </div>
      </el-form-item>

      <div class="list-scroll-setting">
        <div class="title-info">
          <el-divider content-position="left">列表设置</el-divider>
        </div>
        <el-form-item label="候诊类型设置" class="wait-patient-set">
          <el-radio-group v-model="optionsInfo.waitPatientType">
            <el-radio :label="item.value" v-for="item in waitPatientTypeOptions" :key="item.value">
              {{ item.label }}
            </el-radio>
          </el-radio-group>
        </el-form-item>


        <el-form-item label="子元素背景">
          <el-switch v-model="optionsInfo.itemShadow"/>
        </el-form-item>

        <el-form-item label="开启滚动" v-if="false">
          <el-switch v-model="optionsInfo.openScroll"/>
        </el-form-item>
        <el-form-item label="滚动速度" v-if="false">
          <el-input-number
              v-model="optionsInfo.scrollStep"
              :min="0"
              :max="4"
              :disabled="!(optionsInfo.openScroll)"
              size="small"
              class="hide-spin-button"
          />
        </el-form-item>
        <el-form-item label="是否切屏" v-if="false">
          <el-switch v-model="optionsInfo.switchScreen"></el-switch>
        </el-form-item>
        <el-form-item label="切屏时间(s)" class="switching-screen">
          <el-input-number
              :min="10"
              :step="1"
              size="small"
              class="hide-spin-button"
              v-model="optionsInfo.switchTime"
              :disabled="!(optionsInfo.switchScreen)"
          />
        </el-form-item>
      </div>

      <!--等待就诊滚动设置-->
      <div class="wait-visit-setting">
        <div class="title-info">
          <el-divider content-position="left">等待就诊</el-divider>
        </div>
        <el-form-item label="开启滚动">
          <el-switch v-model="optionsInfo.openScroll"/>
        </el-form-item>

        <el-form-item label="开启滚动数量">
          <el-input-number
              :min="0"
              :max="8"
              size="small"
              class="hide-spin-button"
              :disabled="!(optionsInfo.openScroll)"
              v-model="optionsInfo.waitingNumber"
          />
        </el-form-item>
        <el-form-item label="滚动速度">
          <el-input-number
              :min="1"
              :max="5"
              size="small"
              class="hide-spin-button"
              :disabled="!(optionsInfo.openScroll)"
              v-model="optionsInfo.waitingVisitStep"
          />
        </el-form-item>
        <el-form-item label="滚动方向" v-if="false">
          <el-radio-group
              size="small"
              :disabled="!(optionsInfo.openScroll)"
              v-model="optionsInfo.waitingVisitDirection"
          >
            <el-radio label="up">上下</el-radio>
            <el-radio label="left">左右</el-radio>
          </el-radio-group>
        </el-form-item>
      </div>

      <div class="list-item-setting">
        <el-divider content-position="left">呼叫患者弹层显示设置</el-divider>
        <el-form-item label="设置显示" class="call-patient-set">
          <el-checkbox-group
              v-if="callPatientOptions&&callPatientOptions.length"
              v-model="optionsInfo.checkList">
            <el-checkbox
                v-for="item in callPatientOptions"
                :label="item.value"
                :key="item.value"
                :disabled="item.value===3"
                @change="(e)=>handleChange(e, item)"
            >
              {{ item.label }}
            </el-checkbox>
          </el-checkbox-group>
        </el-form-item>
      </div>

      <div class="list-item-setting">
        <el-divider content-position="left">信息发布设置</el-divider>
        <el-form-item label="标题设置" class="call-patient-set">
          <div class="header-wrap">
            <el-input
                placeholder="请输入内容"
                v-model="optionsInfo.headerTitle"
            />
          </div>
        </el-form-item>


        <el-form-item label="正文设置" class="call-patient-set">
          <div class="header-wrap">
            <el-button type="primary" @click="handleSelect('formVideoInfo',(optionsInfo.infoContent))">素材选择</el-button>
          </div>
        </el-form-item>

        <el-form-item label="视频声音" class="call-patient-set" v-if="false">
          <div class="header-wrap">
            <el-input-number
                :min="0"
                :max="10"
                :step="1"
                size="small"
                class="hide-spin-button"
                v-model="optionsInfo.infoContent.sound"
            />
          </div>
        </el-form-item>

      </div>

      <SelectVideoText
          :info="formVideoInfo.info"
          :visible="formVideoInfo.visible"
          :multiple="formVideoInfo.multiple"
          :infoContent="formVideoInfo.infoContent"
          @handleCancel="handleCancel"
          @handleSure="handlePublishSure"
      />

    </template>
  </div>
</template>

<script>
import Draggable from "vuedraggable";
import constantDic from "@/utils/vue-i18n/lang/zh-CN";
import SelectVideoText from "@c/public/layer/template/selectVideoText/index.vue";
import roomNameKeyEditor
  from "@sc/templateDetails/modules/homeRight/property-editor/module/scene-edit/basicInfo/roomNameKey-editor.vue";
import * as types from "@c/public/form-designer/devType/datas-types";
export default {
  name: "waitingQueueInfoPublicInfoConfig-editor",

  componentName: "waitingQueueInfoPublicInfoConfig-editor",

  components: {
    roomNameKeyEditor,
    Draggable,
    SelectVideoText
  },

  mixins: [],

  props: {
    designer: Object,
    selectedWidget: Object,
    optionModel: Object,
  },

  inject: ['serverFieldList', 'getDesignerConfig'],

  data() {
    return {
      materialInfo:{
        visible: false,
        info:1,
      },
      constantDic: constantDic,
      optionsInfo: Object(),
      predefineColors: types['predefineColors'],
      waitPatientTypeOptions:types['waitPatientTypeOptions'],
      callPatientOptions: [
        {
          value: 1,
          label: '科室'
        },
        {
          value: 2,
          label: '号别'
        },
        {
          value: 3,
          label: '诊室'
        }
      ],
      formVideoInfo: {
        info: Object(),
        visible: false,
        multiple: false,
      },
    }
  },

  computed: {
    isDisabled() {
      return function (val) {
        let arr = [];
        return arr.includes(val);
      }
    },

    registerObjNameOptions(){
      return this.$store.getters['templateDetails/getRegisterObjNameOptions']
    }
  },


  mounted() {},

  methods: {
    handleDragEnd() {},

    // 科室诊室&号别--科室和好别不能共存
    handleChange(val, row) {
      let value = (row.value);
      let {checkList} = (this.optionsInfo);
      if (value === 1) {
        if (val) {
          this.$lodash.pull(checkList, 2);
        }
      }
      if (value === 2) {
        if (val) {
          this.$lodash.pull(checkList, 1);
        }
      }
    },


    // 选择素材
    handleSelect2(){
      Reflect.set((this.materialInfo),'visible', true);
      Reflect.set((this.materialInfo),'info', 1)
      Reflect.set((this.materialInfo),'multiple',true);
      Reflect.set((this.materialInfo),'infoContent', (this.optionsInfo.infoContent));
    },


    handleSelect(val, content) {
      let params = Object();
      switch (val) {
        case 'formVideoInfo':
          // 查找资源库对应的资源
          Reflect.set(params, 'type', 'video');
          // 修改对应的字段
          Reflect.set(params, 'updataType', 'video');
          let contents = Object();
          Reflect.set(contents, 'tabsName', content['tabsName']);
          Reflect.set(contents, 'textContent', content['textContent']);
          Reflect.set(contents, 'videoContent', content['videoContent'])
          Reflect.set(contents, 'pictureContent', content['pictureInfo'])
          // 旧的数据
          Reflect.set(params, 'content', contents);
          Reflect.set((this.formVideoInfo), 'infoContent', contents);
          Reflect.set((this.formVideoInfo), 'visible', true);
          Reflect.set((this.formVideoInfo), 'info', params);
          Reflect.set((this.formVideoInfo), 'multiple', true);
          console.log(this.formVideoInfo)
          break;
      }
    },


    // 取消弹层
    handleCancel(){
      Reflect.set((this.formVideoInfo),'visible', false);
    },

    // 信息发布
    handlePublishSure(valInfo) {
      let {tabsName, textContent,videoContent,pictureContent} = valInfo;
      Reflect.set((this.optionsInfo.infoContent), 'tabsName', tabsName);
      switch (tabsName) {
        case "textarea":
          Reflect.set((this.optionsInfo.infoContent), 'textContent', textContent);
          break
        case "video":
          Reflect.set((this.optionsInfo.infoContent), 'videoContent', videoContent);
          break
        case "picture":
          Reflect.set((this.optionsInfo.infoContent), 'pictureInfo', pictureContent);
          break
      }
    },
  },

  watch: {
    optionModel: {
      handler: function (val) {
        this.optionsInfo = (val[val.config]);
      },
      deep: true,
      immediate: true
    }
  }

}
</script>

<style lang="scss" scoped>
.switching-screen {
  ::v-deep .el-input-number__decrease {
    margin-top: 1px;
  }

  ::v-deep .el-input-number__increase {
    margin-top: 1px;
  }
}

.call-patient-set {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    @include fontWeight();
    width: 100% !important;
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;

    .el-checkbox-group {
      display: flex;
      flex-direction: column;
    }
  }

}

.col-info {

  ::v-deep .el-form-item__content {
    margin-left: 1px !important;

    .title {
      width: 100%;
    }

    .el-checkbox__label {
      width: auto;
    }


    .el-icon-thumb {
      position: relative;
      top: 8px;
      padding-left: 10px;
      font-size: 18px;
      text-align: center;
    }

    .el-checkbox {
      width: calc(100% - 32px);
    }
  }

}

//号别简称
.register-info{
  :deep(.el-form-item__content) {
    margin-left: 1px !important;

    .title {
      width: 100%;
    }
    .el-radio-group{
      .el-radio{
        width: 100%;
        padding: 8px 0;
      }
    }
  }
}

.wait-patient-set {
  display: flex;
  flex-direction: column;

  :deep(.el-form-item__label) {
    width: 100% !important;
  }

  :deep(.el-form-item__content) {
    margin-left: 0 !important;;

    .el-radio-group {
      display: flex;
      flex-direction: column;

      .el-radio {
        padding: 10px 0;
      }
    }
  }

}
</style>